package com.ruoyi.web.controller.teacher;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.SysClasses;
import com.ruoyi.teacher.service.ISysClassesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * sysClassesController
 * @author ruoyi
 * @date 2022-01-13
 */
@Controller
@RequestMapping("/teacher/classes")
public class SysClassesController extends BaseController
{
    private String prefix = "teacher/classes";

    @Autowired
    private ISysClassesService sysClassesService;

    @RequiresPermissions("teacher:classes:view")
    @GetMapping()
    public String classes()
    {
        return prefix + "/classes";
    }

    /**
     * 查询sysClasses列表
     */
    @RequiresPermissions("teacher:classes:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysClasses sysClasses)
    {
        startPage();
        List<SysClasses> list = sysClassesService.selectSysClassesList(sysClasses);
        return getDataTable(list);
    }

  /*  *//**
     * 导出sysClasses列表
     *//*
    @RequiresPermissions("teacher:classes:export")
    @Log(title = "sysClasses", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysClasses sysClasses)
    {
        List<SysClasses> list = sysClassesService.selectSysClassesList(sysClasses);
        ExcelUtil<SysClasses> util = new ExcelUtil<SysClasses>(SysClasses.class);
        return util.exportExcel(list, "学生数据");
    }
*/
   /* @RequiresPermissions("teacher:classes:view")
    @GetMapping("/importTemplate")
    @ResponseBody
    public AjaxResult importTemplate()
    {
        ExcelUtil<SysClasses> util = new ExcelUtil<SysClasses>(SysClasses.class);
        return util.importTemplateExcel("学生数据");
    }

    @Log(title = "学生管理", businessType = BusinessType.IMPORT)
    @RequiresPermissions("teacher:classes:import")
    @PostMapping("/importData")
    @ResponseBody
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<SysClasses> util = new ExcelUtil<SysClasses>(SysClasses.class);
        List<SysClasses> userList = util.importExcel(file.getInputStream());
        String message = sysClassesService.importStudent(userList, updateSupport, getLoginName());
        return AjaxResult.success(message);
    }*/

    /**
     * 新增sysClasses
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存sysClasses
     */
    @RequiresPermissions("teacher:classes:add")
    @Log(title = "sysClasses", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysClasses sysClasses)
    {
        sysClasses.setCreateBy(getLoginName());
        return toAjax(sysClassesService.insertSysClasses(sysClasses));
    }

    /**
     * 修改sysClasses
     */
    @RequiresPermissions("teacher:classes:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysClasses sysClasses = sysClassesService.selectSysClassesById(id);
        mmap.put("sysClasses", sysClasses);
        return prefix + "/edit";
    }

    /**
     * 修改保存sysClasses
     */
    @RequiresPermissions("teacher:classes:edit")
    @Log(title = "sysClasses", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysClasses sysClasses)
    {
        sysClasses.setUpdateBy(getLoginName());
        return toAjax(sysClassesService.updateSysClasses(sysClasses));
    }

    /**
     * 删除sysClasses
     */
    @RequiresPermissions("teacher:classes:remove")
    @Log(title = "sysClasses", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysClassesService.deleteSysClassesByIds(ids));
    }


/*
    */
/**
     * 校验用户名
     *//*

    @PostMapping("/checkCardUnique")
    @ResponseBody
    public String checkCardUnique(SysClasses sysClasses)
    {
        return sysClassesService.checkCardUnique(sysClasses.getCard());
    }

    @PostMapping("/checkClassesIdUnique")
    @ResponseBody
    public String checkClassesIdUnique(SysClasses sysClasses)
    {
        return sysClassesService.checkClassesIdUnique(sysClasses.getClassesId());
    }
*/


}
